package com.wr.activeMQ;

import org.springframework.jms.annotation.JmsListener;
import org.springframework.stereotype.Component;

import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Map;

@Component
public class Consumer {

    // 使用JmsListener配置消费者监听的队列，其中text是接收到的消息
    @JmsListener(destination = "mytest.queue")
    public void receiveQueue(byte[] data) throws IOException {
        System.out.println("Consumer收到报文");
        FileOutputStream fo;
        String path = "headImg/";
        long fileName = System.currentTimeMillis();
        String contentType = "jpg";
        fo = new FileOutputStream("C:\\Users\\Administrator\\Desktop\\手机相册\\"+
                path+fileName+"."+contentType);
        fo.write(data);
        fo.flush();
        fo.close();
    }
}
